package com.bank.controller.login;

import com.bank.controller.login.MyInterceptor1;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

@Configuration
public class WebSecurityConfig extends WebMvcConfigurerAdapter {


    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/");
        super.addResourceHandlers(registry);
    }

   /* @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/");
        registry.addResourceHandler("/templates/**").addResourceLocations("classpath:/templates/");

        super.addResourceHandlers(registry);
    }*/
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 多个拦截器组成一个拦截器链
        // addPathPatterns 用于添加拦截规则
        // excludePathPatterns 用户排除拦截
        registry.addInterceptor(new MyInterceptor1()).addPathPatterns("/**")
                .excludePathPatterns("/dl/tologin") //登录页
                .excludePathPatterns("/dl/login")
                .excludePathPatterns("/dl/zhuce")
                .excludePathPatterns("/dl/tozhuce")
                .excludePathPatterns("/static/**");
               // .excludePathPatterns("/bank/index") ;
       // registry.addInterceptor(new MyTokenSession()).addPathPatterns("/**");
               /* .excludePathPatterns("/hlladmin/user/register") //用户注册
                .excludePathPatterns("/hlladmin/user/login"); //用户登录*/

        super.addInterceptors(registry);
    }

}

